package com.it.testDemo;

import com.it.autowire.Emp;
import com.it.bean.Orders;
import com.it.collection.Course;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestFactoryBean {
    @Test
    public void test(){
        ApplicationContext context=new ClassPathXmlApplicationContext("bean3.xml");
        Course course = context.getBean("mybean", Course.class);
        System.out.println(course);
    }
    @Test
    public void test2(){
   //     ApplicationContext context=new ClassPathXmlApplicationContext("bean4.xml");
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("bean4.xml");
        Orders order = context.getBean("Order", Orders.class);
        System.out.println("第四步：获取创建bean实例对象");
        System.out.println(order);
        //手动让bean实例销毁
        context.close();
    }
    @Test
    public void test3(){
        ApplicationContext context=new ClassPathXmlApplicationContext("bean5.xml");
        Emp emp = context.getBean("emp", Emp.class);
        System.out.println(emp);
        emp.test();
    }
}
